package com.seed.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Top {

    private final Top1 top1;
    private final Top2 top2;

    public Top(Top1 top1, @Autowired(required = false) Top2 top2) {
        this.top1 = top1;
        this.top2 = top2;
    }

    public void say() {
        System.out.println("please say:");
        top1.say();
        if(top2 != null) top2.say();
    }
}
